﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


using KingRoad.EPM.PersonnelLogEntity.Model;
using Unis.Framework.Core.Utility;
using KingRoad.EPM.PersonnelLogDAL.PlmSpecialtylogService;


namespace KingRoad.EPM.PersonnelLogBLL.UIRules
{
    /// <summary> 
    /// 客户端业务处理类。 
    /// 文件生成时间 2017/1/12 13:58:21
    /// </summary> 
    public class PlmSpecialtylogUIRule
    {
        private readonly IPlmSpecialtylogService _plmSpecialtylogService;


        public PlmSpecialtylogUIRule() { }

        /// <summary> 
        /// construct function... 
        /// </summary> 
        public PlmSpecialtylogUIRule(IPlmSpecialtylogService plmSpecialtylogService)
        {
            _plmSpecialtylogService = plmSpecialtylogService;
        }


        public List<PlmSpecialtylogInfo> GetAllPlmSpecialtylog()
        {
            var list = _plmSpecialtylogService.GetEntityList();
            return list;
        }


        public PlmSpecialtylogInfo GetPlmSpecialtylogInfoById(string slId)
        {
            var sqlStr = String.Format(" Sl_ID='{0}' ", slId);
            var single = _plmSpecialtylogService.GetEntityList(sqlStr).FirstOrDefault();
            return single;
        }

        public bool InsertEntity(PlmSpecialtylogInfo entity)
        {
            var ret = _plmSpecialtylogService.InsertEntity(entity);
            return ret > 0;
        }

        public bool UpdateEntity(PlmSpecialtylogInfo entity)
        {
            var ret = _plmSpecialtylogService.UpdateEntity(entity);
            return ret > 0;
        }

        public bool DeleteEntity(string slId)
        {
            var ret = _plmSpecialtylogService.DeleteEntityByStringID(slId);
            return ret > 0;
        }

        /// <summary>
        /// 根据条件查询信息
        /// </summary>
        /// <param name="numCurrentPage">当前页</param>
        /// <param name="numPerPage">每页数据大小</param>
        /// <param name="orderByField">排序字段名称</param>
        /// <param name="totalRecord">总数据量</param>
        /// <param name="sqlCondition">sql查询条件</param>
        /// <returns></returns>
        public List<PlmSpecialtylogInfo> GetSpecialtylogForPage(int numCurrentPage, int numPerPage, string orderByField, out int totalRecord, string sqlCondition)
        {
            var list = _plmSpecialtylogService.GetEntityListByContionRe(numCurrentPage, numPerPage, orderByField, out totalRecord, sqlCondition);
            return list;
        }

        /// <summary>
        /// 判断是否存在AssisId
        /// </summary>
        /// <param name="assisId"></param>
        /// <returns></returns>
        public bool IsExitAssistId(int assisId)
        {
            var strSql = String.Format(" Assist_ID={0} ", assisId);
            var list = _plmSpecialtylogService.GetEntityList(strSql);
            return list.Any();
        }
    }
}
